import React from 'react';
import './App.css';
import {BrowserRouter as Router, Switch, Route, Redirect} from 'react-router-dom'

// 页面
import Layout from './components/layout';
// 页面
import Home from './page/home';
import ProductRouter from './page/product/router'
import Login from './page/login';
import ErrorPage from './page/error';
import UserList from './page/user/index'
import OrderList from './page/order/index'
import OrderDetail from './page/order/detail'

let LayoutRouter = (
	<Layout>
		<Switch>
			<Route exact path="/" component={Home}></Route>
			<Route path="/product" component={ProductRouter}></Route>
			<Route path="/product-category" component={ProductRouter}></Route>
			<Route path="/user/index" component={UserList}></Route>
			<Route path="/order/index" component={OrderList}></Route>
			<Route path="/order/detail/:orderNumber" component={OrderDetail}></Route>
			<Redirect exact from="/user" to="/user/index" />
			<Redirect exact from="/order" to="/order/index" />
			<Route component={ErrorPage}/>
		</Switch>
	</Layout>
)
function App() {
  return (
    <div className="App">
			<Router>
				<Switch>
					<Route path="/login" component={Login}></Route>
					<Route path="/" render={(props) => (
						LayoutRouter
					)} />
				</Switch>
			</Router>
    </div>
  );
}

export default App;
